<?php 
require_once 'common/common.inc.php';

$selected_date = isset($_REQUEST["date"]) ? $_REQUEST["date"] : "";
$selected_start_time = isset($_REQUEST["start_time"]) ? $_REQUEST["start_time"] : "";
$selected_minutes = isset($_REQUEST["minutes"]) ? $_REQUEST["minutes"] : "";
$reservation_id = isset($_REQUEST["reservation_id"]) ? $_REQUEST["reservation_id"] : "";
$start_datetime = $selected_date.' '.$selected_start_time;

$start_date = new DateTimeDutch("@".strtotime($start_datetime), $timezone);
$start_date->setTimezone($timezone); 

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

  conn();
  $sql = "DELETE FROM RESERVATIONS WHERE ID = '$reservation_id' ";
  //echo $sql;
  $result = mysql_query($sql);
  if (!$result) {die('Could not exec query: ' . mysql_error());}
  close();
  
  // redirect to the same page without the POST data
  header("Location: ".$_SERVER['PHP_SELF']."?date=$selected_date&start_time=$selected_start_time&minutes=$selected_minutes&reservation_id=$reservation_id");
  die;
}

?>

<?php 
include 'common/page.begin.inc.php';
?>

<body>

<div id="wrapper">

  <?php 
  $menuSelected = "diensten";
  $subMenuSelected = "knippen";
  include 'common/body.header.inc.php';
  ?>

  <div id="page" class="container">
  
    <div id="content">

      <?php
      $contentPath = "Knippen &gt;&gt; Afspraak Maken";
      include 'common/body.content.header.inc.php';
      ?>
      
      <div class="main-top">
        <div class="first knippen">
        </div>  
        <div class="second">
          <div class="content-blok">

            <?php 
            include 'common/body.error.inc.php';
            ?>

            <?php if (empty($error)) { ?>
              <h2>De reservering is verwijderd</h2>
              
              <p>
                De volgende reservering is verwijderd:<br />
                <?php echo $start_date->format('l d F Y \o\m H:i');?>
              </p>
              
              <p>
                <a href="01_knippen.php">Klik hier om een nieuwe afspraak te maken.</a>
              </p>
              
            <?php } ?>
      
          </div><!-- end content blok -->  
        </div><!-- end second -->  
      </div><!-- end home top -->

    </div><!-- end content -->

    <div style="clear: both;"></div>
	</div><!-- end page -->  
  
  <?php 
  include 'common/body.footer.inc.php';
  ?>
  
</div><!-- end wrapper -->

<?php 
include 'common/page.end.inc.php';
?>


